package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.client.enums.TriggerStrategy;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalKeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.DamageFeeAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
@AttrHandler(DamageFeeAttrHandler.class)
public class DamageFeeAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {

    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {
        if (TriggerStrategy.LOAD_VALUE.equals(data.getTriggerStrategy())) {
            //是否收取违约金
            KiteAttr damageFeeSwitchAttr = inst.getAttr("210004554");
            //违约金收取方式
            KiteAttr DamageFeeRuleAttr = inst.getAttr("210004555");
            if (Objects.isNull(DamageFeeRuleAttr)) {
                return;
            }
            if ("110007675".equals(DamageFeeRuleAttr.getValue()) && KiteStringUtils.isNotEmpty(attr.getValue())) {
                damageFeeSwitchAttr.setIsNull(LocalKeyConsts.IFTRUE_F);
                damageFeeSwitchAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_D);
            }
        }
    }
}
